Socket
Socket
Sign inDemoInstall

easydate

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

easydate

get date and/or time by pattern


Version published
Weekly downloads
129
increased by16.22%
Maintainers
1
Weekly downloads
 
Created
Source

easydate Build Status js-standard-style

Returns the date according to a pattern.

Installation

$ npm install easydate

Test:

$ npm test

Usage/API

easydate(patternString, [inputDate])

The single exported function has two arguments. The first and only required argument is the pattern string (see Pattern Options below). If only including the pattern string it will return a formatted string for the current date-time, if the optional input date string is supplied, that particular date will be returned formatted. This input date string must be parseable by JavaScript's Date.parse function; see below for acceptable examples.

Examples:

var easydate = require('easydate');

// current date/time
easydate('d-M-y'); // "28-01-14"
easydate('d/M/Y'); // "28/01/2014"
easydate('Y.M.d'); // "2014.01.28"
easydate('M'); // "01"
easydate('d-M-Y @ h:m:s.l'); // "29-01-2014 @ 07:22:37.418"

// specified date/time
easydate('d-M-Y @ h:m', '2015-11-03T16:06:00.000Z'); // "03-11-2015 @ 16:06"
easydate('h:m:s.l', '2015-11-03T16:06:08.123Z'); // "16:06:08.123"
easydate('M~d~Y', '03-01-2017'); // "03~01~2017"

Pattern Options

Case sensitive.

  • Y Full year (nnnn)
  • y Year (nn)
  • M Month (nn)
  • d Day (nn)
  • h Hour (nn)
  • m Minute (nn)
  • s Second (nn)
  • l Millisecond (nnn)

Caveats

Any instances of the above characters will be replaced with the relevant numbers. It is recommended to not use words within the pattern string.

License

MIT

Keywords

FAQs

Package last updated on 29 May 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc